package control;

import service.UserService;
import vo.Users;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.util.List;

@WebServlet("/user_list.action")
public class UserListControl extends HttpServlet {

    private UserService service = UserService.getInstance();

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取客户端发送过来的参数
        request.setCharacterEncoding("UTF-8");
        String username = request.getParameter("username");
        List<Users> userList = service.queryUserList(username);
        request.setAttribute("userList", userList);
        request.setAttribute("username", username);
        request.getRequestDispatcher("./user_list.jsp").forward(request,response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
